import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import axios from "axios";
//引入bootstrap,不在app引入的原因：样式隔离
import "bootstrap/dist/css/bootstrap.min.css";
import 'easymde/dist/easymde.min.css'

axios.defaults.baseURL = "http://apis.imooc.com/api";
axios.interceptors.request.use((config) => {
  config.params = { ...config.params, icode: "C47F851009F72942" };
  if (config.data instanceof FormData) {
    config.data.append("icode", "C47F851009F72942");
  } else {
    config.data = { ...config.data, icode: "C47F851009F72942" };
  }
  store.commit("setLoading", true);
  store.commit('setError', { status: false, message: ''})
  return config
})

axios.interceptors.response.use(config => {
  setTimeout(() => {
    store.commit("setLoading", false)
  },3000)
   return config
},e => {
  console.log(e.response)
  const { error } = e.response.data
  store.commit('setError', { status: true, message: error})
  store.commit('setLoading', true)
  return Promise.reject(error)
})
// axios.get('/columns').then(res => {
//     console.log(res.data);
// })
// axios.get('/columns', { params: {page:'1', Size: '10'} }).then(res => {
//     console.log(res.data);

// })
createApp(App).use(store).use(router).mount("#app");
